package com.day16.Poker;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.TreeSet;

public class PokerDemo2 {
    public static void main(String[] args){
        HashMap<Integer,String>hm=new HashMap<Integer,String>();
        ArrayList<Integer>array=new ArrayList<Integer>();
        String[] colors={"红桃","黑桃","梅花","方片"};
        String[] numbers={"A","2","3","4","5","6","7","8","9","10","J","Q","K"};
        int index=0;
        for(String nmumber:numbers){
            for(String color:colors){
                hm.put(index,""+color+nmumber);
                array.add(index);
                index++;
            }
        }
        hm.put(index,"小王");
        array.add(index);
        index++;
        hm.put(index,"大王");
        array.add(index);
        array.add(index);
        Collections.shuffle(array);
        TreeSet<Integer>lqxSet=new TreeSet<Integer>();
        TreeSet<Integer>lySet=new TreeSet<Integer>();
        TreeSet<Integer>fqySet=new TreeSet<Integer>();
        TreeSet<Integer>dpSet=new TreeSet<Integer>();
        for(int i=0;i<array.size();i++){
            int x=array.get(i);
            if (i >= array.size() - 3) {
                dpSet.add(x);
            } else if (i % 3 == 0) {
                lqxSet.add(x);
            } else if (i % 3 == 1) {
                lySet.add(x);
            } else if (i % 3 == 2) {
                fqySet.add(x);
            }
        }
        lookPoker("丽群香",lqxSet,hm);
        lookPoker("李阳",lySet,hm);
        lookPoker("方庆阳",fqySet,hm);
        lookPoker("底牌",dpSet,hm);
        }
        public static void lookPoker(String name,TreeSet<Integer>set,HashMap<Integer,String>hm){
            System.out.print(name+"的牌是：");
            for(int x:set){
                System.out.print(hm.get(x)+" ");
            }
            System.out.println();
        }
    }

